package org.onvivals.admin.module.ums.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onvivals.common.param.PageParam;
import org.onvivals.common.web.PageResult;
import org.onvivals.common.web.Result;
import org.onvivals.module.ums.entity.UmsUser;
import org.onvivals.module.ums.param.UmsMemberParam;
import org.onvivals.module.ums.service.IUmsUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Mr.ZS
 * @Date: 2024/2/20 12:09
 * @company 湖南葆龄科技有限公司
 **/
@Slf4j
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping("/member")
public class MemberController {

	private final IUmsUserService pmsMemberService;

	@GetMapping
	public Result<PageResult<UmsUser>> list(UmsMemberParam param) {
		PageParam<UmsUser, UmsMemberParam> page = new PageParam<>(param);
		page.setDefaultOrder("create_time desc");
		IPage<UmsUser> pa = pmsMemberService.page(page, page.getWrapper());
		PageResult<UmsUser> pageResult = new PageResult<>(pa.getRecords(), pa.getTotal());
		return Result.OK(pageResult);
	}

}
